/*  FTP_Action.h
 *  by vess
 */

#ifndef _FTP_ACTION_H
#define _FTP_ACTION_H

#define NAMELEN 20
#define BUFSIZE 65535
#define RESPONSEBUF 100
#define CLIENTNAME 512

/* FTP_Checksize
 * [in]  com_socket  command_socket
 * [in]  monitor	 monitor
 * [in]  filename    file to check size
 * [in]  filenamelength
 * [ret] file size, -1 for error.
 */
long FTP_GetSize(SOCKET com_socket, SOCKET monitor, char *filename, int filenamelength);

/* FTP_Transferfile
 * [in]  com_socket command_socket
 * [in]  monitor    monitor_port
 * [in]  filename   file to fetch
 * [ret] file size, -1 for error.
 */
long FTP_FetchFile(SOCKET com_socket, SOCKET monitor, char *filename);

/* FTP_Getresponse
 * [in]  com_socket command_socket
 * [in]  buffer     buffer
 * [ret] response length
 */
int FTP_GetResponse(SOCKET com_socket, char *buffer);

/* FTP_GenPasvSocket
 * [in]  response   the response
 * [in]  length     the response length
 * [ret] Socket     for data-pipe
 */
SOCKET FTP_GenPasvSocket(char *response, int length);

/* FTP_ChecksizePasv
 * [in]  com_socket  command_socket
 * [in]  data_socket data_socket
 * [in]  filename    file to check size
 * [in]  filenamelength
 * [ret] file size, -1 for error.
 */
long FTP_GetSizePasv(SOCKET com_socket, SOCKET data_socket, char *filename, int filenamelength);

/* FTP_TransferfilePasv
 * [in]  com_socket command_socket
 * [in]  data_socket data_socket
 * [in]  filename   file to fetch
 * [ret] file size, -1 for error.
 */
long FTP_FetchFilePasv(SOCKET com_socket, SOCKET data_socket, char *filename);

/* FTP_Get
 * [in]  ip, port
 * [in]  user, user_length
 * [in]  password, password_length
 * [in]  file, file_length  
 * [in]  pasv, use passive mode, 1 for passive mode, others for port
 * [ret] 0 for ok, -1 for error.
 */
int FTP_Get(char* ip, char* port, char* user, int user_length, char* password, int password_length, char* file, int file_length, int pasv);
#endif 